package com.ahp.action;

import java.util.List;

import com.ahp.bean.Tast;
import com.ahp.bean.User;
import com.ahp.service.TaskService;

public class TaskAction extends CommonActionSupport {
	private static final long serialVersionUID = 1L;
	private Tast task;
	private TaskService taskService;
	
	public TaskService getTaskService() {
		return taskService;
	}

	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

	public Tast getTask() {
		return task;
	}

	public void setTask(Tast task) {
		this.task = task;
	}

	public String addTask() {
		taskService.addTask(task);
		getSession().put("task", task.getTastId());
		return SUCCESS;
	}
	
	public String getMyTasks(){
		User user = (User)getSession().get(User.USER_SESSION);
		//taskService.delNotHasScoreTask(user);
		List<Tast> list = taskService.getMyTasks(user.getId());
		getRequest().setAttribute("tasksList", list);
		return SUCCESS;
	}
	
	public String delTask(){
		taskService.delTask(task);
		return SUCCESS;
	}
}
